Add getAccountResources method to Wallet class#8173
Merged
bhavidhingra merged 1 commit intomasterfrom Mar 9, 2026
Merged
Conversation
Copilot
AI
changed the title
[WIP] Add getAccountResources method to wallet class
Add getAccountResources method to Wallet class
Feb 18, 2026
Contributor
bhavidhingra
left a comment
There was a problem hiding this comment.
@copilot We have to change the implementation a bit, this operation will not belong to a wallet. It is agnostic of a wallet.
Author
Moved the method from |
Copilot
AI
changed the title
Add getAccountResources method to Wallet class
Add getAccountResources method to BaseCoin class
Feb 19, 2026
Contributor
bhavidhingra
left a comment
There was a problem hiding this comment.
@copilot Sorry, we have to pivot back to using the wallet specific API. Please revert back to using it as was done earlier.
Author
Copilot
AI
changed the title
Add getAccountResources method to BaseCoin class
Add getAccountResources method to Wallet class
Feb 19, 2026
ca445f8 to
2c533ce
Compare
5c2716d to
6d7e006
Compare
6d7e006 to
7038a4f
Compare
ravibitgo
reviewed
Mar 6, 2026
TICKET: CHALO-206
7038a4f to
d286299
Compare
mrdanish26
approved these changes
Mar 6, 2026
kaustubhbitgo
approved these changes
Mar 9, 2026
ravibitgo
approved these changes
Mar 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
getAccountResources()method to Wallet class for querying account resources from the WP API endpoint.Changes
iWallet.ts): AddedGetAccountResourcesOptionsinterface and method signature toIWalletinterfacewallet.ts): Implemented method with options object pattern, array validation and query parameter handling inWalletclasswallet/getAccountResources.ts): Added unit tests covering success paths and error casesMethod Signature
Where
GetAccountResourcesOptionsis defined as:Calls
GET /accountResourceswith addresses as a required parameter and optionaldestinationAddressfor computing resource deficits needed for an asset transfer.Usage
Example Output
Running against a testnet USDT wallet (
ttrx:usdt):{ "resources": [ { "address": "TWpHQPy2CBwJ5opNF1ugRY357vMDPNLEGK", "free_bandwidth_available": 600, "free_bandwidth_used": 0, "staked_bandwidth_available": 0, "staked_bandwidth_used": 0, "energy_available": 0, "energy_used": 0, "resourceDeficitForAssetTransfer": { "bandwidthDeficit": 0, "bandwidthSunRequired": "0", "energyDeficit": 28045, "energySunRequired": "1993" }, "maxResourcesDelegatable": { "bandwidthWeight": "0", "energyWeight": "0" } } ], "failedAddresses": [] }Key fields explained:
free_bandwidth_available/staked_bandwidth_available: Bandwidth from free daily allocation and TRX staking respectively.energy_available: Energy the address currently has (from staking or delegation).resourceDeficitForAssetTransfer: The shortfall in bandwidth and energy needed for a token transfer to the destination address. Here the address needs 28,045 energy (costing 1,993 SUN ≈ 0.001993 TRX) to perform a USDT transfer, but has no bandwidth deficit.maxResourcesDelegatable: The maximum bandwidth/energy weight this address can delegate to others (zero here since nothing is staked).